<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>事件流示例</title>
</head>
<body>
    <div>
        <p>
            <a href="#">连接</a>
        </p>
    </div>
    <script>
        
        let div = document.querySelector("div");
        let p = document.querySelector("p");
        let a = document.querySelector("a");
        document.body.onclick = function(){
            console.log("body");
        }
        div.onclick = function(){
            console.log("div");
        }
        p.onclick = function(){
            console.log("p");
        }
        a.onclick = function(){
            console.log("a");
        }
        document.body.addEventListener("click",function(){
            console.log("捕获事件body");
        },true);
        div.addEventListener("click",function(){
            console.log("捕获事件div");
        },true);
        p.addEventListener("click",function(){
            console.log("捕获事件p");
        },true);
        a.addEventListener("click",function(){
            console.log("捕获事件a");
        },true);
    </script>
</body>
</html>